package org.huang.sample09;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @描述：
 * @作者: Mr.huang
 * @创建时间: 2017/8/21 16:05
 * @版本: 1.0
 */
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptRepository deptRepository;

    @GetMapping("/all")
    public List<Dept> all(){
        return deptRepository.findAll();
    }

    @GetMapping("/code/{code}")
    public List<Dept> findByCode(@PathVariable String code){
        return deptRepository.findAllByCodeLike(code);
    }

}
